Request Processing
Because your derived media handler is based on the base media handler component, you avoid many of the details involved in creating a media handler. However, your derived media handler must observe a few rules when processing service requests. These rules are as follows:
-
When you receive an open request from the Component Manager, in addition to the other processing you perform on your own behalf, you must also open a connection to the base media handler component. You should save the component instance that is returned by the Component Manager so that your media handler can use the services of the base media handler.
-
The base media handler has a component type of
MediaHandlerType
(which is set to
'mhlr'
) and a component subtype of
BaseMediaType
(which is set to
'gnrc'
). You can use these values with the Component Manager's
OpenDefaultComponent
function to open a connection to the base media handler.
-
At this time, you must also tell the base media handler that your handler is derived from it. Use the Component Manager's
OpenComponent
function to create a component instance of your media handler as a descendant of the base media handler. After calling that function, you should send the
kComponentSetTargetSelect
request to the base media handler, so that it knows your media handler is derived from it. Use the Component Manager's
ComponentSetTarget
function to send a target request.
-
When you receive a close request from the Component Manager, be sure to close your handler's connection to the base media handler component. Use the Component Manager's
CloseComponent
function.
-
Your derived media handler must support the target request, so that your component can be used by other media handlers.
-
Be sure to pass all unsupported service requests to the base media handler component. Use the Component Manager's
DelegateComponentCall
function to pass these requests to the base media handler.
-
If your media handler component competes for potentially scarce system resources, your component should release those resources when you aren't using them. For example, if you are creating a media handler that uses sound, you might use sound channels. Because there are a limited number of sound channels available, your component should free its channels whenever your media is not playing or has been stopped. You can reallocate the channels when you start playing or your component's
MediaPreroll
function is called.
© 1997 Apple Computer, Inc.Previous | Chapter Top | Chapter Contents | Next